<%--
    Document   : listcustype
    Created on : Nov 24, 2011, 12:03:45 AM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*, Beans.ThamSoHT,Models.ThamSoHT_Model"%>
<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'customertype', 'customertypelist', 'mark', 'notice', 'order', 'reduction', 'rightmsg' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String customertype = mdsts[0].getTenTS();
            String customertypelist = mdsts[1].getTenTS();
            String mark = mdsts[2].getTenTS();
            String notice = mdsts[3].getTenTS();
            String order = mdsts[4].getTenTS();
            String reduction = mdsts[5].getTenTS();
            String rightmsg = mdsts[6].getTenTS();

            String msgright = notice + "/" + rightmsg;

            Vector vDSLKH = (Vector) request.getAttribute("DSLKH");
            int numpage = 0;// khởi tạo số trang = 0
            int vsize = vDSLKH.size();
            if (vsize % 4 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 4;
            } else {
                numpage = vsize / 4 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String tenlkh = (String) request.getAttribute("tenlkh");
            String sodiem = (String) request.getAttribute("sodiem");
            String chietkhau = (String) request.getAttribute("chietkhau");

%>
<div class="title">
        <%=customertypelist %>
        
    </div>
    <div class="content">
        <form name="dsnhommonan" action="">
            <table class="mytable" border="0" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <th style="width: 10%;  "><%=order%></th>
                        <th style="width: 36%; ">
                            <a href="#" id="titledskv1" style="margin-top: 5px;" class="down" name="1" lang="<%=msgright%>" onclick="SortSearchTenLKH(this.className, this.name, this.lang)">
                                <div style="float:left"><%=customertype %></div>
                                <div id="sortkv1" style=" margin-right: 30px;" class="down1"></div>
                            </a>
                        </th>
                        <th style="width: 26%; ">
                            <a href="#" id="titledskv2" style="margin-top: 5px;" class="down" name="1" lang="<%=msgright%>" onclick="SortSearchSoDiem(this.className, this.name, this.lang)">
                                <div style="float:left"><%=mark %></div>
                                <div id="sortkv2" style=" margin-right: 35px;" class="down1"></div>
                            </a>
                        </th>
                        <th>
                            <a href="#" id="titledskv3" style="margin-top: 5px;" class="down" name="1" lang="<%=msgright%>" onclick="SortSearchChietKhau(this.className, this.name, this.lang)">
                                <div style="float:left"><%=reduction %></div>
                                <div id="sortkv3" style=" margin-right: 40px;" class="down1"></div>
                            </a>
                        </th>
                        <th></th>
                    </tr>
                    <tr id="searchLKH">
                        <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" alt="1" src="../images/search1.png" lang="<%=msgright%>" onclick="SearchLKH(this.alt, this.lang)"></th>
                        <th><input type="textbox" value="<%=tenlkh%>" style=" width: 120px;" class="tenlkh text" ></th>
                        <th><input type="textbox" value="<%=sodiem%>" style=" width: 45px;" onkeypress="return keypress(event)" class="sodiem text" ></th>
                        <th><input type="textbox" value="<%=chietkhau%>" style=" width: 45px;" onkeypress="return keypress(event)" class="chietkhau text"  maxlength="2">   %</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <%
                        for (int i = (item - 1) * 4; i < (item - 1) * 4 + 4 && i < vsize; i++) {
                            Beans.LoaiKH lkh = (Beans.LoaiKH) vDSLKH.elementAt(i);
                    %>
                    <tr>
                        <td class="STT"><%= i + 1%></td>
                        <td><a href="#" name="<%=lkh.getMaLKH() %>" lang="<%=msgright%>" onclick="ShowLangCT(this.name, this.lang)"><%=lkh.getTenLKH() %></a></td>
                        <td><%=lkh.getSoDiem() %></td>
                        <td><div style="float: left; width: 40px; padding-left: 10px;"><%=lkh.getChietKhau() %></div>   %</td>
                        <td></td>
                    </tr>
                    <%  }
                    %>
                </tbody>
            </table>
                <div class="pagination">
                    <%
                                int trang = 1;
                                if (item > 1) {
                                    trang = item - 1;
                                }
                    %>
                    <%
                                if (vsize > 4) {%>
                    <a href="#" class="prev"  name="<%= trang%>" lang="<%=msgright%>" onclick="SearchLKH( this.name, this.lang)">«</a>
                    <%
                                                for (int c = 1; c <= numpage; c++) {

                                                    if (c != item) {
                    %> <a href="#"  name="<%= c%>" lang="<%=msgright%>" onclick="SearchLKH(this.name, this.lang)" ><%= c%></a>
                    <% } else {%><a class="current"> <%= c%></a> <% }

                                                }
                    %>
                    <%
                                                if (item + 1 <= numpage) {
                                                    trang = item + 1;
                                                } else {
                                                    trang = item;
                                                }
                    %>
                    <a href="#" class="next"  name="<%= trang%>" lang="<%=msgright%>" onclick="SearchLKH( this.name, this.lang)">»</a>

                    <%  }
                    %>
                </div>
        </form>
    </div>